//
//  YHVistorTableViewController.swift
//  SniaWeiBo
//
//  Created by lcc on 16/5/11.
//  Copyright © 2016年 lcc. All rights reserved.
//

import UIKit

class YHVistorTableViewController: UITableViewController {

    //用户是否登录的标记
    var userLogin = false
    
    var vistorView: YHView?
    
    override func loadView() {
        
        if userLogin {
            
            super.loadView()
        }else {
            vistorView = YHView()
            
            //回调网页
            vistorView?.closureBag = {[weak self] in
                print(self)
                self?.requestOAuthLogin()
            }
            
            view = vistorView
            
            //创建按钮
            setUpNavUI()
        }
    }
    
   private func setUpNavUI() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", fontSize: 15, target: self, action: "registerButton")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", fontSize: 15, target: self, action: "loginButton")
    
    }
    
    //登录注册按钮功能实现
   @objc private func registerButton() {
        print("registerButton1")
    
        requestOAuthLogin()
    }
    
   @objc private func loginButton() {
        print("loginButton1")
    
        requestOAuthLogin()
    }
    
    
    private func requestOAuthLogin() {
        
        let oAuthVC = YHOAuthViewController()
        let nav = UINavigationController(rootViewController: oAuthVC)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
    }

}